package com.cx.simpleweb;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.*;

import java.io.File;


@SpringBootApplication
@RequestMapping
@RestController
@EnableAsync

//@EnableTransactionManagement(proxyTargetClass = true)
public class SimplewebApplication {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    @Qualifier("starter")
    private String firstName;

    @Autowired
    private I a;

    @GetMapping("test2")
    public String test2(){
        File toolsJar = new File(System.getProperty("java.home"), "../lib/tools.jar");
        return System.getProperty("java.home")+":"+toolsJar.isFile () + ":" + toolsJar.canRead ();
    }


    @GetMapping("test")
    public String test(){
        a.test1 ();
//        SecurityContext context = SecurityContextHolder.getContext ();
//        userMapper.insert ();
        return firstName;
    }

    @RequestMapping("gw")
    public String demo(){
//        SecurityContext context = SecurityContextHolder.getContext ();
//        userMapper.insert ();
        return firstName;
    }

//    @PostMapping("login")
//    public String login(){
//        return "OKK";
//    }

    public static void main(String[] args) {
        SpringApplication.run (SimplewebApplication.class, args);
    }

}
